#include <iostream>
#include <string>

// 产品类：汽车
class Car {
public:
    void setEngine(const std::string& engine) {
        m_engine = engine;
    }

    void setWheels(int wheels) {
        m_wheels = wheels;
    }

    void setSeats(int seats) {
        m_seats = seats;
    }

    void showInfo() {
        std::cout << "Car with " << m_engine << " engine, " << m_wheels << " wheels, and " << m_seats << " seats." << std::endl;
    }

private:
    std::string m_engine;
    int m_wheels;
    int m_seats;
};

// 抽象建造者类
class CarBuilder {
public:
    virtual void buildEngine() = 0;
    virtual void buildWheels() = 0;
    virtual void buildSeats() = 0;
    virtual Car* getCar() = 0;
};

// 具体建造者类：家用汽车建造者
class FamilyCarBuilder : public CarBuilder {
public:
    FamilyCarBuilder() {
        m_car = new Car();
    }

    void buildEngine() override {
        m_car->setEngine("Gasoline");
    }

    void buildWheels() override {
        m_car->setWheels(4);
    }

    void buildSeats() override {
        m_car->setSeats(5);
    }

    Car* getCar() override {
        return m_car;
    }

private:
    Car* m_car;
};

// 指导者类：汽车制造公司
class CarManufacturer {
public:
    Car* buildCar(CarBuilder* builder) {
        builder->buildEngine();
        builder->buildWheels();
        builder->buildSeats();
        return builder->getCar();
    }
};

//int main() {
//    // 创建汽车制造公司
//    CarManufacturer manufacturer;
//
//    // 创建家用汽车建造者
//    FamilyCarBuilder familyCarBuilder;
//
//    // 指导公司使用家用汽车建造者来构建汽车
//    Car* familyCar = manufacturer.buildCar(&familyCarBuilder);
//
//    // 展示构建的家用汽车信息
//    std::cout << "Family Car: ";
//    familyCar->showInfo();
//
//    // 释放资源
//    delete familyCar;
//
//    return 0;
//}
